package cn.stylefeng.guns.modular.biz.controller;

import cn.stylefeng.guns.modular.biz.entity.PrWeightSumOrder;
import cn.stylefeng.guns.modular.biz.pojo.request.PrWeightSumOrderRequest;
import cn.stylefeng.guns.modular.biz.service.PrWeightSumOrderService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * MES计量汇总单控制器
 *
 * @author 张朋飞
 * @since 2024/09/29 21:24
 */
@RestController
@ApiResource(name = "MES计量汇总单")
public class PrWeightSumOrderController {

    @Resource
    private PrWeightSumOrderService prWeightSumOrderService;

    /**
     * 添加MES计量汇总单
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @PostResource(name = "添加MES计量汇总单", path = "/prWeightSumOrder/add")
    public ResponseData<PrWeightSumOrder> add(@RequestBody @Validated(PrWeightSumOrderRequest.add.class) PrWeightSumOrderRequest prWeightSumOrderRequest) {
        prWeightSumOrderService.add(prWeightSumOrderRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 删除MES计量汇总单
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @PostResource(name = "删除MES计量汇总单", path = "/prWeightSumOrder/delete")
    public ResponseData<?> delete(@RequestBody @Validated(PrWeightSumOrderRequest.delete.class) PrWeightSumOrderRequest prWeightSumOrderRequest) {
        prWeightSumOrderService.del(prWeightSumOrderRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 批量删除MES计量汇总单
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @PostResource(name = "批量删除MES计量汇总单", path = "/prWeightSumOrder/batchDelete")
    public ResponseData<?> batchDelete(@RequestBody @Validated(BaseRequest.batchDelete.class) PrWeightSumOrderRequest prWeightSumOrderRequest) {
        prWeightSumOrderService.batchDelete(prWeightSumOrderRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 编辑MES计量汇总单
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @PostResource(name = "编辑MES计量汇总单", path = "/prWeightSumOrder/edit")
    public ResponseData<?> edit(@RequestBody @Validated(PrWeightSumOrderRequest.edit.class) PrWeightSumOrderRequest prWeightSumOrderRequest) {
        prWeightSumOrderService.edit(prWeightSumOrderRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 查看MES计量汇总单详情
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @GetResource(name = "查看MES计量汇总单详情", path = "/prWeightSumOrder/detail")
    public ResponseData<PrWeightSumOrder> detail(@Validated(PrWeightSumOrderRequest.detail.class) PrWeightSumOrderRequest prWeightSumOrderRequest) {
        return new SuccessResponseData<>(prWeightSumOrderService.detail(prWeightSumOrderRequest));
    }

    /**
     * 获取MES计量汇总单列表
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @GetResource(name = "获取MES计量汇总单列表", path = "/prWeightSumOrder/list")
    public ResponseData<List<PrWeightSumOrder>> list(PrWeightSumOrderRequest prWeightSumOrderRequest) {
        return new SuccessResponseData<>(prWeightSumOrderService.findList(prWeightSumOrderRequest));
    }

    /**
     * 获取MES计量汇总单列表（带分页）
     *
     * @author 张朋飞
     * @since 2024/09/29 21:24
     */
    @GetResource(name = "获取MES计量汇总单列表（带分页）", path = "/prWeightSumOrder/page")
    public ResponseData<PageResult<PrWeightSumOrder>> page(PrWeightSumOrderRequest prWeightSumOrderRequest) {
        return new SuccessResponseData<>(prWeightSumOrderService.findPage(prWeightSumOrderRequest));
    }

}
